package org.wmq.taskschedule.config;

import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.wmq.taskschedule.service.ThreadPoolService;
import org.wmq.taskschedule.service.impl.ThreadPoolServiceImpl;

@Configuration
@ConfigurationProperties(prefix = "custom.thread.pool")
public class ThreadPoolConfig {
    
    // 这些属性可以在application.properties或application.yml中配置
    private Integer corePoolSize;
    private Integer maximumPoolSize;
    private Long keepAliveTime;
    private Integer queueCapacity;
    
    @Bean
    public ThreadPoolService threadPoolService() {
        // 创建并返回线程池服务实例
        return new ThreadPoolServiceImpl();
    }
    
    // Getters and Setters
    public Integer getCorePoolSize() {
        return corePoolSize;
    }
    
    public void setCorePoolSize(Integer corePoolSize) {
        this.corePoolSize = corePoolSize;
    }
    
    public Integer getMaximumPoolSize() {
        return maximumPoolSize;
    }
    
    public void setMaximumPoolSize(Integer maximumPoolSize) {
        this.maximumPoolSize = maximumPoolSize;
    }
    
    public Long getKeepAliveTime() {
        return keepAliveTime;
    }
    
    public void setKeepAliveTime(Long keepAliveTime) {
        this.keepAliveTime = keepAliveTime;
    }
    
    public Integer getQueueCapacity() {
        return queueCapacity;
    }
    
    public void setQueueCapacity(Integer queueCapacity) {
        this.queueCapacity = queueCapacity;
    }
}